﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using DotNet.Business;
using DotNet.Model;
using DotNet.Common;

public partial class Admin_AdminPageSeo : basePage
{
    pageSeoBll seoBll = new pageSeoBll();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Request.QueryString["state"] != null)
            {
                string state = Request.QueryString["state"].ToString();
                switch (state.Trim())
                {
                    case "add":
                        add();
                        break;
                    case "del":
                        delete(Convert.ToInt32(Request.QueryString["id"]));
                        break;
                    default:
                        break;
                }
            }
            this.Repeater1.DataSource = seoBll.GetModel();
            this.Repeater1.DataBind();

        }


    }
    private void delete(int id)
    {

        if (seoBll.Delete(id))
        {
            Response.End();
        }
        else
        {
            Response.Write("删除错误");
        }

    }
    private void add()
    {
        if (Request.Form["Title"].ToString()=="")
        {
            Response.Write("标题不能为空");
            Response.End();
        }
        pageSeo pSeo = new pageSeo();
        pSeo.Title = Request.Form["Title"].ToString();
        pSeo.pageKey = Request.Form["key1"].ToString() + "," + Request.Form["key2"].ToString() + "," + Request.Form["key3"].ToString() + "," + Request.Form["key4"].ToString() + "," + Request.Form["key5"].ToString() + "," + Request.Form["key6"].ToString();
        pSeo.Description = Request.Form["Description"].ToString();
        pSeo.pageTop = Request.Form["pageTop"].ToString();
        pSeo.Bottom = Request.Form["Bottom"].ToString();
        pSeo.pageName = Request.Form["pageName"].ToString();
        pSeo.fromPage = Request.Form["fromPage"].ToString();
        if (seoBll.Insert(pSeo))
        {
            Response.Write("1");
            Response.End();
        }

    }
}
